<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue 条件 v-if, v-show</title>
    <script src="./js/vue.min.js"></script>
    <style>
        div {
            margin: 30px 0;
        }
        
    </style>
</head>

<body>

    <div id="vm">

        <div>
            设置a的值 <input type="text" v-model="a" />
        </div>

        <div v-if="a==1">
            v-if 如果条件不成立 不会创建此标签
        </div>
        
        <div v-show="a==1">
            v-show 如果条件不成立  会创建此标签，但是css样式 为不显示
        </div>

        <div v-if="a == 1">
            A
          </div>
          <div v-else-if="a == 2">
            B
          </div>
          <div v-else-if="a == 3">
            C
          </div>
          <div v-else>
            Not A/B/C
          </div>

        <div>
            <button v-on:click="setShow()">显示</button>
            <button v-on:click="setHide()">隐藏</button>
        </div>

    </div>

    <script>
        var vm01 = new Vue({
            el: '#vm',
            data: {
                a: 0
            },
            computed: {
                
            },
            methods: {
                setShow() {
                    this.a = 1;
                },
                setHide() {
                    this.a = 0;
                }
            }
        })
    </script>

</body>

</html>